<!DOCTYPE html>
<?php
include __DIR__ . '/loader.php';

//~ $sql = "SELECT count(*) FROM `kata_dasar` WHERE `tipe` <> ''";
$sql = "SELECT DISTINCT (kata) as word FROM `daftar_kata_quran` WHERE jenis_kata = ''";
foreach ($pdo->query($sql) as $row) {
    echo $row['word'].'<br/>';
}
/*
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    </head>
    <body>
        <form method="post" action="">
            <textarea name="text" style="width: 561px; height: 192px;"></textarea>
            <br/>
            <input type="submit" name="search" value="Search">
        </form>

        <?php
        include __DIR__ . '/loader.php';
        require_once __DIR__ . '/../vendor/autoload.php';

        $preProses      = new PreProcessing($pdo);
        $rulePertanyaan = new RulePertanyaanSatu($pdo);
        $stemming       = new EcsStemming($pdo);

        $stemmerFactory = new \Sastrawi\Stemmer\StemmerFactory();
        $stemmer  = $stemmerFactory->createStemmer();

        //$stemmer->stem($sentence);

        if (isset($_POST['search'])) :
            echo '<strong>TEXT : </strong><br/>';
            echo $_POST['text'];
            echo '<br/><br/><strong>HASIL : </strong><br/>';
            // $result = $rulePertanyaan->ruleApa($_POST['text']);
            $result = $rulePertanyaan->qas($_POST['text']);
            ?>
            <table border="1">
                <thead>
                    <tr>
                        <th rowspan="2">No</th>
                        <th rowspan="2">Surat</th>
                        <th rowspan="2">Ayat</th>
                        <th colspan="2">Score</th>
                        <th rowspan="2">Total Score</th>
                        <th rowspan="2">Text Indonesia</th>
                        <th rowspan="2">Text Arab</th>
                    </tr>
                    <tr>
                        <th>WordMatch</th>
                        <th>Rule</th>
                    </tr>
                </thead>
                <tbody>
                    <?php 
                    $no = 1;
                    foreach ($result as $key => $dataSura):
                        // var_dump($dataSura);
                        ?>
                    <tr>
                        <td><?php echo $no ?></td>
                        <td><?php echo $dataSura['sura'] ?></td>
                        <td><?php echo $dataSura['aya'] ?></td>
                        <td>
                            <?php
                            foreach ($dataSura['data'] as $jenis => $data) :
                                if ($jenis == 'wordmatch'):
                                    foreach ($data as $kata => $value) {
                                        echo $kata.' -> '.$value['score'].'<br/>';
                                    }
                                endif;
                            endforeach; //end for dataSura
                            ?>
                        </td>
                        <td>
                            <?php
                            foreach ($dataSura['data'] as $jenis => $data) :
                                if ($jenis == 'rule1' || $jenis == 'rule2'):
                                    echo $jenis.'<br/>';
                                    foreach ($data as $kata => $value) {
                                        echo $kata.' -> '.$value['score'].'<br/>';
                                    }
                                    echo '<br/>';
                                endif;
                            endforeach; //end for dataSura
                            ?>
                        </td>
                        <?php
                        foreach ($dataSura['data'] as $jenis => $data) :
                            if ($jenis == 'total' || $jenis == 'indonesia' || $jenis == 'arabic'):
                                echo '<td>'.$data.'</td>';
                            endif;
                        endforeach; //end for dataSura
                        ?>
                    </tr>
                    <?php
                    endforeach; //sura
                    ?>
                </tbody>
            </table>
            <?php
        endif;
        ?>
    </body>
</html>
*/
